From b30afff511d14165e81806a8c90a9a33e77dbb69 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 6 Nov 2016 21:36:43 +0100 Subject: [PATCH] API: wayland: Add gdk_wayland_window_new_subsurface() ... and use it instead of gdk_window_new(). --- docs/reference/gdk/gdk4-sections.txt | 1 + gdk/wayland/gdkwaylandwindow.h | 4 ++++ gdk/wayland/gdkwindow-wayland.c | 35 ++++++++++++++++++++++++++++ gtk/gtkwindow.c | 33 +++++++++++--------------- 4 files changed, 54 insertions(+), 19 deletions(-) diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt index 12a569351e..65d7e138f4 100644 --- a/docs/reference/gdk/gdk4-sections.txt +++ b/docs/reference/gdk/gdk4-sections.txt @@ -1174,6 +1174,7 @@ gdk_wayland_device_get_wl_seat gdk_wayland_display_get_wl_compositor gdk_wayland_display_get_wl_display gdk_wayland_display_get_xdg_shell +gdk_wayland_window_new_subsurface gdk_wayland_window_get_wl_surface gdk_wayland_window_set_use_custom_surface GdkWaylandWindowExported diff --git a/gdk/wayland/gdkwaylandwindow.h b/gdk/wayland/gdkwaylandwindow.h index 566d40524c..628204ff4a 100644 --- a/gdk/wayland/gdkwaylandwindow.h +++ b/gdk/wayland/gdkwaylandwindow.h @@ -45,6 +45,10 @@ typedef struct _GdkWaylandWindowClass GdkWaylandWindowClass; GDK_AVAILABLE_IN_ALL GType gdk_wayland_window_get_type (void); +GDK_AVAILABLE_IN_3_90 +GdkWindow * gdk_wayland_window_new_subsurface (GdkDisplay *display, + int event_mask, + const GdkRectangle *position); GDK_AVAILABLE_IN_ALL struct wl_surface *gdk_wayland_window_get_wl_surface (GdkWindow *window); diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c index 837fde9c8c..d8e1ec5efa 100644 --- a/gdk/wayland/gdkwindow-wayland.c +++ b/gdk/wayland/gdkwindow-wayland.c @@ -3672,6 +3672,41 @@ _gdk_wayland_window_set_grab_seat (GdkWindow *window, impl->grab_input_seat = seat; } +/** + * gdk_wayland_window_new_subsurface: (constructor) + * @display: the display to create the window on + * @event_mask: event mask (see gdk_window_set_events()) + * @position: position relative to the transient window + * + * Creates a new subsurface window. + * + * Returns: (transfer full): the new #GdkWindow + * + * Since: 3.90 + **/ +GdkWindow * +gdk_wayland_window_new_subsurface (GdkDisplay *display, + int event_mask, + const GdkRectangle *position) +{ + GdkWindowAttr attr; + + g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL); + g_return_val_if_fail (position != NULL, NULL); + + attr.event_mask = event_mask; + attr.wclass = GDK_INPUT_OUTPUT; + attr.x = position->x; + attr.y = position->y; + attr.width = position->width; + attr.height = position->height; + attr.window_type = GDK_WINDOW_SUBSURFACE; + + return gdk_window_new (gdk_screen_get_root_window (gdk_display_get_default_screen (display)), + &attr, + GDK_WA_X | GDK_WA_Y); +} + /** * gdk_wayland_window_get_wl_surface: * @window: (type GdkWaylandWindow): a #GdkWindow diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 7cb88d7893..764cbf5ff7 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -6370,21 +6370,10 @@ popover_realize (GtkWidget *widget, #ifdef GDK_WINDOWING_WAYLAND if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (widget))) { - GdkWindowAttr attributes; - gint attributes_mask; - - attributes.window_type = GDK_WINDOW_SUBSURFACE; - attributes.wclass = GDK_INPUT_OUTPUT; - attributes.x = rect.x; - attributes.y = rect.y; - attributes.width = rect.width; - attributes.height = rect.height; - attributes.event_mask = gtk_widget_get_events (popover->widget) | - GDK_EXPOSURE_MASK; - attributes_mask = GDK_WA_X | GDK_WA_Y; - - popover->window = gdk_window_new (gdk_screen_get_root_window (_gtk_window_get_screen (window)), - &attributes, attributes_mask); + popover->window = gdk_wayland_window_new_subsurface (gtk_widget_get_display (GTK_WIDGET (window)), + gtk_widget_get_events (popover->widget) + | GDK_EXPOSURE_MASK, + &rect); gdk_window_set_transient_for (popover->window, _gtk_widget_get_window (GTK_WIDGET (window))); } @@ -6973,12 +6962,18 @@ gtk_window_realize (GtkWidget *widget) #ifdef GDK_WINDOWING_WAYLAND if (priv->use_subsurface && GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (widget))) - attributes.window_type = GDK_WINDOW_SUBSURFACE; + { + gdk_window = gdk_wayland_window_new_subsurface (gtk_widget_get_display (widget), + attributes.event_mask, + &allocation); + } else #endif - attributes.window_type = GDK_WINDOW_TEMP; - gdk_window = gdk_window_new (gdk_screen_get_root_window (_gtk_window_get_screen (window)), - &attributes, 0); + { + attributes.window_type = GDK_WINDOW_TEMP; + gdk_window = gdk_window_new (gdk_screen_get_root_window (_gtk_window_get_screen (window)), + &attributes, 0); + } break; default: g_warning (G_STRLOC": Unknown window type %d!", priv->type); -- 2.30.2